package com.allinpay.merchantweb.common.utils;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.Model;

import com.allinpay.merchantweb.common.exception.ViewException;
import com.allinpay.merchantweb.constants.ReturnCodeConstants;

public class SessionUtil {

     private static final Logger logger = LoggerFactory.getLogger(SessionUtil.class);
    
	 public static String isInSession2(Model model, HttpServletRequest request) {
		    String sessionId=request.getRequestedSessionId();
		    logger.info("current sessionId:"+sessionId);
	        try {
	            
	            if (null == sessionId) {
	                throw new ViewException(ReturnCodeConstants.H5LOGIN_000005, "Session超时请重试");
	            }
	            
	        } catch (ViewException e) {
	            logger.error("session is not exist ViewException:" + e);
	            model.addAttribute("code", e.getErrorCode());
	            model.addAttribute("msg", e.getErrorMsg());
	            return "error";
	        } catch (Exception e) {
	            logger.error("session is not exist Exception:" + e);
	            model.addAttribute("code", "");
	            model.addAttribute("msg", "未知页面异常");
	            return "error";
	        }
	        return null;
	    }
}
